package service

import (
	"rongyy/src/models"
)

type InpatientReserveService struct {
}

func (pc *InpatientReserveService) Apply(req *models.IpReserveModel) error {
	req.Status = "pending"
	err := req.Insert()
	return err
}

func (pc *InpatientReserveService) Approve(req *models.ReqIpsHandelModel) error {

	model := &models.IpReserveModel{}
	model.Status = "approve"
	model.OperatorCode = req.OperatorCode
	model.Id = req.Id
	err := model.Update()
	return err
}

func (pc *InpatientReserveService) Confirm(id int64) error {
	model := &models.IpReserveModel{}
	model.Status = "confirm"
	model.Id = id
	err := model.Update()
	return err
}

func (pc *InpatientReserveService) Reject(req *models.ReqIpsHandelModel) error {

	model := &models.IpReserveModel{}
	model.Status = "reject"
	model.OperatorCode = req.OperatorCode
	model.Id = req.Id
	model.RejectReason = req.Reason
	err := model.Update()
	return err
}

func (pc *InpatientReserveService) Query(req *models.ReqIpReserveQuery) ([]models.IpReserveModel, int64, error) {
	model := &models.IpReserveModel{}
	list, total, err := model.Query(req)
	if err != nil {
		return nil, 0, err
	}
	return list, total, nil
}
